﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Network
{
    public partial class Form1 : Form
    {
      


        public Form1()
        {
            InitializeComponent();
           
        }

        private void apprentissage_Click(object sender, EventArgs e)
        {
            Apprentissage app = new Apprentissage(Program.NombreNeurones, Program.IndividualNumber, Program.generationNumber);                      
        }

        private void check_Click(object sender, EventArgs e)
        {
            int age = int.Parse(age_tb.Text);
            int annee = int.Parse(annee_tb.Text);
            int ganglions = int.Parse(ganglions_tb.Text);
            double[] outputHidden = new double [Program.NombreNeurones];
            double res = 0;
            Network network = Program.bestNetwork;


             for (int i = 0; i < Program.NombreNeurones; i++)
            {
                network.getHiddenNeuronal()[i].setInputValue(age, annee, ganglions);
                outputHidden[i] = network.getHiddenNeuronal()[i].getOutput();
            }

             network.getFinalNeuronal().setValueInput(outputHidden);
             


             double min = network.getFinalNeuronal().getWeigth(Program.NombreNeurones - 1);
             double max = 0;
             for (int j = 0; j < Program.NombreNeurones + 1; j++)
             {
                 max += network.getFinalNeuronal().getWeigth(j);
             }
             double min_res = (1.0 / (1 + Math.Exp(-min)));
             double max_res = (1.0 / (1 + Math.Exp(-max)));
             double limite = ((min_res + max_res) / 2);

             res =  network.getFinalNeuronal().getOutput();

            /* if (res > limite)
             {
                 System.Console.WriteLine("1");
             }
             else
             {
                 System.Console.WriteLine("2");
             }*/


             //  r.getFinalNeuronal().findError(int.Parse(input[3]));
             //  r.setError(r[line_number].getFinalNeuronal().getFinalError());

             // sortie = Math.Round(res, 2);
            
            
            //double survive = network.Survive(age, annee, ganglions,network);
            System.Console.WriteLine(res);


        }
    }
}
